/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Materials;

import Raytracing.BRDF.BlendBRDF;
import Raytracing.Shaders.Shader;
import Raytracing.BRDF.LambertBRDF;
import Raytracing.BRDF.SpecularReflectionBRDF;
import Raytracing.FresnelDielectric;
import Raytracing.Shaders.SolidTexture;
import SGGUI.GUIComponent;
import SGGUI.GUIEvent;
import SGGUI.GUIListener;
import SGGUI.SGSlider;
import TweetRay.Exportable;
import Materials.MaterialFactory.Materials;
import TweetRay.UTFReader;
import TweetRay.UTFWriter;
import processing.core.PVector;

/**
 *
 * @author Matt
 */
public class ShinyPlasticShader extends SingleColorShader implements Exportable {

    public ShinyPlasticShader(UTFReader reader) {
        super("Plastic", reader);
        
        type = Materials.PLASTIC.ordinal();
        

        LambertBRDF shad = new LambertBRDF(new SolidTexture(color));
        SpecularReflectionBRDF mirror = new SpecularReflectionBRDF(new FresnelDielectric(.177f, 3.6f), new PVector(.911f, .83f, .76f));
        BlendBRDF plastic = new BlendBRDF(shad, mirror, new SolidTexture(new PVector(.75f, 0, 0)));

        addBRDF(plastic);
        init();
    }

    public ShinyPlasticShader(String name, PVector color) {
        super(name);
        type = Materials.PLASTIC.ordinal();
        setColor(color);

        LambertBRDF shad = new LambertBRDF(new SolidTexture(color));
        SpecularReflectionBRDF mirror = new SpecularReflectionBRDF(new FresnelDielectric(.177f, 3.6f), new PVector(.911f, .83f, .76f));
        BlendBRDF plastic = new BlendBRDF(shad, mirror, new SolidTexture(new PVector(.75f, 0, 0)));

        addBRDF(plastic);

    }

    public void pack(UTFWriter output) {

        output.writeBits(Materials.PLASTIC.ordinal(), 5);
        writeColorBits(output);

    }

    public void GUIEventPerformed(GUIEvent e) {
        //I don't understand why I have to do this...
        //but if I don't the caller pretends it can't see calls to the superclass..
        super.GUIEventPerformed(e);
    }
}